package cn.ytnet.shangyun.service.basic.entity;

import org.springframework.stereotype.Component;

import javax.persistence.*;

/**
 * Created by cyongk on 2015/12/8.
 * ClassName：GoodsSubSortEntity
 * ChineseName：商品子分类
 */
@Component("goodsSubSortEntity")
@Entity
@Table(name = "T_GoodsSubSort", schema = "crebas", catalog = "")
public class GoodsSubSortEntity {
    private String pkTGoodssubsortId;
    private String subsortName;
    private String subsortPhoneticcode;

    private GoodsTotalSortEntity goodsTotalSortEntity;//商品总分类

    @ManyToOne(cascade = CascadeType.ALL,fetch = FetchType.EAGER)
    @JoinColumn(name = "pk_t_goodsgotalsort_id")
    public GoodsTotalSortEntity getGoodsTotalSortEntity() {
        return goodsTotalSortEntity;
    }

    public void setGoodsTotalSortEntity(GoodsTotalSortEntity goodsTotalSortEntity) {
        this.goodsTotalSortEntity = goodsTotalSortEntity;
    }

    @Id
    @Column(name = "pkT_goodssubsort_id", nullable = false, length = 4)
    public String getPkTGoodssubsortId() {
        return pkTGoodssubsortId;
    }

    public void setPkTGoodssubsortId(String pkTGoodssubsortId) {
        this.pkTGoodssubsortId = pkTGoodssubsortId;
    }

    @Basic
    @Column(name = "subsort_name", nullable = false, length = 30)
    public String getSubsortName() {
        return subsortName;
    }

    public void setSubsortName(String subsortName) {
        this.subsortName = subsortName;
    }

    @Basic
    @Column(name = "subsort_phoneticcode", nullable = false, length = 30)
    public String getSubsortPhoneticcode() {
        return subsortPhoneticcode;
    }

    public void setSubsortPhoneticcode(String subsortPhoneticcode) {
        this.subsortPhoneticcode = subsortPhoneticcode;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        GoodsSubSortEntity that = (GoodsSubSortEntity) o;

        if (pkTGoodssubsortId != null ? !pkTGoodssubsortId.equals(that.pkTGoodssubsortId) : that.pkTGoodssubsortId != null)
            return false;
        if (subsortName != null ? !subsortName.equals(that.subsortName) : that.subsortName != null) return false;
        return subsortPhoneticcode != null ? subsortPhoneticcode.equals(that.subsortPhoneticcode) : that.subsortPhoneticcode == null;

    }

    @Override
    public int hashCode() {
        int result = pkTGoodssubsortId != null ? pkTGoodssubsortId.hashCode() : 0;
        result = 31 * result + (subsortName != null ? subsortName.hashCode() : 0);
        result = 31 * result + (subsortPhoneticcode != null ? subsortPhoneticcode.hashCode() : 0);
        return result;
    }
}
